<template>

  <div class="tabBar">
    <div :key="index" @click="switchBar(el, index)" v-for="(el,index) in sortList">
      <div class="itemView">
        <div style="position: relative">
          <p :style="index === selectedIndex ? 'color: #323334; font-size: 20px;' : 'color: #98999E; font-size: 16px;'"
             class="itemLabel">
            {{el.title}}</p>
          <div class="selectedLine" v-if="index === selectedIndex"></div>
        </div>

      </div>
    </div>
  </div>

</template>

<script>


  export default {
    props: ['sortList'],
    components: {},
    created() {

    },
    data() {
      return {
        selectedIndex: 0,
      }
    },
    methods: {
      switchBar(el, index) {
        this.selectedIndex = index
        this.$emit('sendDataPick', el, index);
      }
    }
  }
</script>

<style scoped>


  .tabBar {
    box-sizing: border-box;
    padding-left: 16px;
    display: flex;
    justify-content: flex-start;
    width: 100%;
    height: 48px;
    overflow-y: hidden;
    overflow-x: scroll;
    white-space: nowrap;
    background: #FBFBFB;
  }

  .tabBar::-webkit-scrollbar {
    display: none;
  }

  .itemView {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    height: 48px;
    margin-right: 24px;
  }

  .itemLabel {
    line-height: 48px;
    font-weight: bold;
    font-size: 16px;
    color: #333333;
  }

  .selectedLine {
    position: absolute;
    /*left: 50%;*/
    /*margin-left: -10px;*/
    bottom: 1px;
    left: calc(50% - 10px);
    /*right: auto;*/
    width: 20px;
    margin-left: auto;
    margin-right: auto;
    background-image: linear-gradient(225deg, #3ECFFA 0%, #1DA1F2 100%);
    height: 4px;
    border-radius: 2px;
  }
</style>
